import {
  navigateTo
} from "../../utils/util.js";

import Request from "../../utils/request";
let app = getApp()

Component({
  /**
   * 组件的属性列表
   */
  properties: {
      // mainData: {
      //     type: Array
      // }
  },

  /**
   * 组件的初始数据
   */
  data: {
    // imgBaseUrl: app.globalData.ENVIRONMENT_CONFIG.imgBaseUrl.split('/static')[0] + '/static/img/',
    // menus: app.globalData.ENVIRONMENT_CONFIG.mainMenus,
      imgBaseUrl: '',
      menus: []
  },
  ready(){
      let _that = this;
      let mainData = [];
      Request.getRequest('/menu/page',{orderBy:'rank',pageNo:1,pageSize:1000}).then(res => {
          let list = res.data;
          for(let i = 0; i < list.length; i++){
              let item = list[i];
              if(item.isShow ===0){
                  continue;
              }
              if(item.isMain == 1){
                  let mainItem = {
                      title: item.title,
                      subTitle: item.menuDesc,
                      img: item.pictureUrl,
                      url: item.skipUrl,
                  }
                  if(null != item.pictureParam && item.pictureParam != ''){
                      mainItem.img += item.pictureParam;
                  }
                  mainData.push(mainItem);
              }             
          }

          console.log("mainData", mainData);
          // temp yangqing  
          mainData = [{
            title: "活动报名",
            subTitle: "新手、训练、PickUp",
            img: "https://wx.jyyy.com.cn:8092/static/photo/appointment.png",
            url: "/pages/activity/activityList/activityList?entryID=1&item=91&dept_type=1&clinicName=消化内科&supClinicName=内科&mode=1",
        },{
          title: "了解MOTIF",
          subTitle: "mine/own/team/i/friend",
          img: "https://wx.jyyy.com.cn:8092/static/photo/health-card.png",
          url: "/pages/activity/activityCreate/activityCreate?entryID=1&item=91&dept_type=1&clinicName=消化内科&supClinicName=内科&mode=1",
      }];    
        

          _that.setData({
              menus: mainData
          })
          // console.log("menus2", this.data.menus2);
      })
      // console.log("menus", this.data.menus);
      // console.log("menus2", this.data.menus2);
      // console.log("mainData", this.properties.mainData);
  },
  /**
   * 组件的方法列表
   */
  methods: {
    goPage(event) {
      let dataset = event.currentTarget.dataset
      if (dataset.disable) {
        wx.showToast({
          title: '维护中',
          icon: 'none',
          duration: 2000
        })
        return
      }
      let url = dataset.url
      navigateTo({
        url: url
      })
    },
  }
})
